package com.hly.tool.login;
/**
 * Copyright Glaway All right reserved.<br>
 * Project：CR929-CheckInFile
 */

import matrix.db.Context;
import matrix.db.JPOSupport;

import java.util.Locale;


/**
 * Description： <br>
 *
 * @Author： Jack.Hao <br>
 * Create Date： 2020年8月31日 <br>
 * @Version： 0.1
 */

public class ContextLoginUtil
{




    /**
     * @return
     * @throws Exception
     */
    public static Context getCasAdminContext(String host, String role, String user, String password) throws Exception
    {
//        String host = CUS_GWJARPropertiesValue.propertiesValue("cas.path").trim();
//        String role=CUS_GWJARPropertiesValue.propertiesValue("adminRole").trim();
//        String host="https://pdmtest.dfac.com/3dspace/";
//        String role="ctx::VPLMProjectLeader.Company Name.test";

        Context context = null;
        try
        {
            String passportTicket = Passport.getTicket(host, user, password);
            context = new Context(host + passportTicket);
            context.setUser(user);
            context.setLocale(new Locale("en-US"));
            context.setRole(role);
            context.connect();
            // Passport环境下必须添加下一行代码，否则 DomainConstants初始化常量时报错
            JPOSupport.registerThread(context);
        } catch (Exception e)
        {
            throw e;
        }
        return context;
    }




}
